import Mock from 'mockjs2'
import { builder, getBody } from '@/mock/util'
import { contractYearNum, depContractNum, amountByYear, amountByDep, certificateNumByYear, certificateNumByDep } from '@/mock/data/chartData'

const contracts = (parameters) => {
  const param = getBody(parameters)
  if (param.x === '年份' && param.y === '数量') {
    return builder(contractYearNum)
  }
  if (param.x === '部门' && param.y === '数量') {
    return builder(depContractNum)
  }
  if (param.x === '年份' && param.y === '金额') {
    return builder(amountByYear)
  }
  if (param.x === '部门' && param.y === '金额') {
    return builder(amountByDep)
  }
}

const certificates = (parameters) => {
  const param = getBody(parameters)
  if (param.x === '年份' && param.y === '数量') {
    return builder(certificateNumByYear)
  }
  if (param.x === '部门' && param.y === '数量') {
    return builder(certificateNumByDep)
  }
}

Mock.mock(/\/statistics\/contracts/, 'post', contracts)
Mock.mock(/\/statistics\/certificates/, 'post', certificates)
